package jcommon.chap9_templating.velocity.demoframework;

import java.io.IOException;
import java.io.StringWriter;

import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;

public abstract class DefautEngineDemo extends VelocityDemo {

	static {
		// Initialize Velocity
		try {
			Velocity.init();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@Override
	protected void processWriterByVolicity(StringWriter writer)
			throws ParseErrorException, MethodInvocationException,
			ResourceNotFoundException, IOException {
		Velocity.evaluate(getVelocityContext(), writer, "test",
				getTemplateReader());
	}

	@Override
	protected final VelocityEngine getVelocityEngine() {
		throw new UnsupportedOperationException(DefautEngineDemo.class.getName()
				+ "不支持此操作");
	}

}
